public class ThreadDemo1 {
    public static void main(String[] args) {

        Thread  t=new Thread(() ->{

            //currentThread是获取当前线程实例
            //currentThread 此时等到的对象就是 t
            // isInterrupted  对象(t)里自带的一个标志位
            while(!Thread.currentThread().isInterrupted())
            {
                System.out.println("hello t");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                    //break;
                }

            }
        });
        t.start();

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //把 t内部的标志位设为true
        t.interrupt();
    }
}
